<template>
  <div>
    <h1>学生管理</h1>
    <AddStudent :stuArray="currentCutObj"></AddStudent>
    <!-- 向子组件传递参数，自定义事件 -->
    <ListStudent :stuArray="currentCutObj" @speak="showStudent" @set="setObj"></ListStudent>
    <UpdateStudent :obj="updateObj"></UpdateStudent>
  </div>
</template>

<script>
import AddStudent from './studentManager/addStudent.vue'
import ListStudent from './studentManager/listStudent.vue'
import UpdateStudent from './studentManager/updateStudent.vue'
export default {
  components: {AddStudent,ListStudent,UpdateStudent},
  data(){
    return{
      currentCutObj:{},
      updateObj:{},
      cutObj1:{
        total:10,
        pages:2,
        list:[{id:1,name:"张三",sex:"男",grade:80},
              {id:2,name:"李四",sex:"男",grade:86},
              {id:3,name:"王五",sex:"男",grade:75},
              {id:4,name:"赵柳",sex:"女",grade:88},
              {id:5,name:"陈琦",sex:"女",grade:95},]
      },
      cutObj2:{
        total:10,
        pages:2,
        list:[{id:11,name:"张三",sex:"男",grade:80},
              {id:12,name:"李四",sex:"男",grade:86},
              {id:13,name:"王五",sex:"男",grade:75},
              {id:14,name:"赵柳",sex:"女",grade:88},
              {id:15,name:"陈琦",sex:"女",grade:95}]
      }
    }
  },
  methods:{
    showStudent(i){
      if(i == 1){
        this.currentCutObj = this.cutObj1
      }else{
        this.currentCutObj = this.cutObj2
      }
    },
    setObj(s){
      this.updateObj = s;
    }
  },
  created(){
    this.showStudent(1);
  }
}
</script>

<style>

</style>